package com.community.service.impl;

import com.community.common.annotation.DataScope;
import com.community.common.utils.DateUtils;
import com.community.common.utils.SecurityUtils;
import com.community.domain.HealthEntity;
import com.community.mapper.HealthMapper;
import com.community.service.HealthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class HealthServiceImpl implements HealthService {
    @Autowired
    private HealthMapper healthMapper;
    @DataScope(deptAlias = "d",userAlias = "u")

    @Override
    public List<HealthEntity> selectHealth(HealthEntity healthEntity) {
        return healthMapper.selectHealth(healthEntity);
    }

    @Override
    public Integer addHealth(HealthEntity healthEntity) {
        healthEntity.setCreateTime(DateUtils.getNowDate());
        healthEntity.setCreateBy(String.valueOf(SecurityUtils.getLoginUser().getUsername()));
        return healthMapper.addHealth(healthEntity);
    }

    @Override
    public Integer editHealth(HealthEntity healthEntity) {
        healthEntity.setUpdateBy(String.valueOf(SecurityUtils.getLoginUser().getUsername()));
        return healthMapper.editHealth(healthEntity);
    }

    @Override
    public Integer deleteHealth(int id) {
        return healthMapper.deleteHealth(id);
    }
}
